package org.example.lyx2022.controller;

import org.example.lyx2022.model.bo.StaffGetStaffInfoInputBO;
import org.example.lyx2022.model.bo.StaffSetStaffInfoInputBO;
import org.example.lyx2022.service.StaffService;
import org.example.lyx2022.service.sqlservice;
import org.fisco.bcos.sdk.transaction.model.dto.TransactionResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class indexController {
    @Autowired
    StaffService staffService;
    @Autowired
    sqlservice Sqlservice;
    @PostMapping(path = "/set")
    public TransactionResponse setStaffInfo(String no, String name)throws Exception{
        StaffSetStaffInfoInputBO staffsetStaffInfoInputBO=new StaffSetStaffInfoInputBO();
        staffsetStaffInfoInputBO.setNo(no);
        staffsetStaffInfoInputBO.setName(name);
        Sqlservice.adduser(no, name);

        return  staffService.setStaffInfo(staffsetStaffInfoInputBO);
    }

    @PostMapping(path = "/get")
    public TransactionResponse setStaffInfo(String no)throws Exception{
        StaffGetStaffInfoInputBO staffGetStaffInfoInputBO=new StaffGetStaffInfoInputBO();
        staffGetStaffInfoInputBO.setNo(no);
        return  staffService.getStaffInfo(staffGetStaffInfoInputBO);
    }
}
